<?php
    header('Access-Control-Allow-Origin:*');
    include_once '../model/model.php';

    $model = new model();
    $model->connect();

    $email =htmlspecialchars($_GET['email']);
    $password = htmlspecialchars($_GET['password']);

    if (!$email) {
        echo "email is empty";
    }

    if (!$password) {
        echo "password is empty";
    }

    if (!$model->selectUserByEmail($email)) {
        echo "no such email";
    }

    $row = $model->checkLogin($email,$password);
    if ($row) {
        $result = array("code"=>1,"result"=>$row);
    } else {
        $result = array("code"=>0);
    }
    echo json_encode($result);
    exit();